Two file archiving utilities for the Unix operating system are CPIO (copy in/out) and TAR (tape archiver). Both utilities can be used for backing up systems, or just to create file archives. They were originally intended to be used with a tape device, although, both create archive files on disk. Another utility, DUMP may also be used to backup a filesystem. A corresponding utility RESTORE restores data from a DUMP backup. RESTORE may be used interactively, to restore only certain files or directories.
In BSD Unix, the TAR utility is implemented as a front-end to the utility PAX. PAX (in one mode) copies file operands to a destination directory. A file operand specifies the pathname of a file to be copied or archived. When a file operand does not select at least one archive member, PAX writes these file operand pathnames in a diagnostic message to standard error and then exits with a non-zero exit status. When no file operands are specified, a list of files to copy with one per line is read from the standard input. When a file operand is a directory, the entire file hierarchy rooted at that directory is included. The effect of the copy is as if the copied files were written to an archive file and then subsequently extracted, except that there may be hard links between the original and the copied files (see the -1 option). While processing a damaged archive during a read or list operation, PAX attempts to recover from media defects and searches through the archive to locate and process the largest number of archive members possible (see the -e option, for more details on error handling).
The directory operand specifies a destination directory pathname. If the directory operand does not exist, or it is not writable by the user, or it is not of type directory, PAX exits with a non-zero exit status. A pattern operand may be used to select one or more pathnames of archive members. Archive members are selected using the pattern matching notation described by fnmatch(3). When the pattern operand is not supplied, all members of the archive are selected. When a pattern matches a directory, the entire file hierarchy rooted at that directory is selected. When a pattern operand does not select at least one archive member, PAX writes the pattern operands in a diagnostic message to standard error and then exits with a non-zero exit status.
When writing an archive, block the output at a positive decimal integer number of
When writing an archive, block the output at a positive decimal integer number of bytes per write to the archive file. The blocksize must be a multiple of 512 bytes with a maximum of 32256 bytes. A blocksize can end with k or b to specify multiplication by 1024 (1K) or 512, respectively. A pair of blocksizes can be separated by x to indicate a product. A specific archive device may impose additional restrictions on the size of blocking it will support. When blocking is not specified, the default blocksize is dependent on the specific archive format being used. The default block size for character special archive files is 10240. All blocksizes less than or equal to 32256 that are multiples of 512 are supported.
Whenever PAX cannot create a file or a link when reading an archive or cannot find a file when writing an archive, or cannot preserve the user ID, group ID, or file mode when the -p option is specified, a diagnostic message is written to standard error and a non-zero exit status will be returned, but processing will continue. In the case where PAX cannot create a link to a file, PAX will not create a second copy of the file. If the extraction of a file from an archive is prematurely terminated by a signal or error, PAX may have only partially extracted a file the user wanted. Additionally, the file modes of extracted files and directories may have incorrect file bits, and the modification and access times may be wrong.
If the creation of an archive is prematurely terminated by a signal or error, PAX may have only partially created the archive which may violate the specific archive format specification. If while doing a copy, PAX detects a file is about to overwrite itself, the file is not copied, a diagnostic message is written to standard error and when PAX completes it will exit with a non-zero exit status.
File archival is also described in U.S. Pat. No. 6,003,044 entitled “Method and Apparatus for Efficiently Backing up Files Using Multiple Computer Systems” by Pongracz, et al. that is incorporated by reference herein in its entirety.